package se.webbzon.oschi01.nbt;

import java.util.Arrays;

import se.webbzon.oschi01.nbt.TagEvent.Action;

public class IntArrayTag extends AbstractTag<int[]> {
	
	private int[] data;
	
	public IntArrayTag(TagFactory<int[]> factory, String tagName, int[] data) {
		super(factory, tagName);
		this.data = data;
	}

	@Override public long size() {
		return 4 * data.length;
	}

	@Override public int[] getValue() {
		return data;
	}

	@Override public void setValue(int[] value) {
		this.data = value;
		broadcastEvent(new TagEvent(this,Action.CHANGED,value));
	}

	@Override public Class<int[]> getValueClass() {
		return int[].class;
	}

	@Override public IntArrayTag clone() {
		int[] copy = Arrays.copyOf(data, data.length);
		return new IntArrayTag(getFactory(),this.toString(),copy);
	}

}
